import { useContext, useState } from "react";
import ContextTodo, { state } from "../../../store/contextTodo"
import ContextChild2 from "./ContextChild2"

const ContextChild1 = () => {
    const context = useContext(ContextTodo)
    const [list, setlist] = useState(state)
    console.log('context初始值', context)
    const updateList = (val) => {
        console.log(val)
    }
    return (<>

        子组件1，使用hook获取context：
        {
            context.todoList.map((item, key) => <p key={key}>{item.title}-level:{item.level}</p>)
        }
        <ContextTodo.Provider value={{ updateList, ...list }}><ContextChild2></ContextChild2></ContextTodo.Provider>
    </>)
}

export default ContextChild1